from django.contrib import admin
from .models import Tag,Category,Post
# Register your models here.
@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
    list_display = ('Tag','id')
    def tag_display(self,obj):
        return ','.join([tag.Tag for tag in obj.tags.all()])
    tag_display.short_description = '标签'
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    list_display = ('Category','id')
    def category_display(self,obj):
        return obj.category.Category
    category_display.short_description = '分类'

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ('title','id','category_display','tags_display')
    list_filter = ('category','tags')
    def tags_display(self,obj):
        return ','.join([tag.Tag for tag in obj.tags.all()])
    tags_display.short_description = '标签'
    def category_display(self,obj):
        return obj.category.Category
    category_display.short_description = '分类'
